package com.tea.tea_vue.Controller;


import com.fasterxml.jackson.core.JsonProcessingException;
import com.tea.tea_vue.Mapper.NewsMapper;
import com.tea.tea_vue.Service.NewService;
import org.springframework.boot.configurationprocessor.json.JSONException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Controller
@RequestMapping("/news")
@CrossOrigin(value = "*")
public class NewsController {
    @Resource
    private NewService newService;
    @Resource
    private NewsMapper newsMapper;

    @GetMapping("/listAll/{pageNum}/{pageSize}")
    @ResponseBody
    public String newsPage(@PathVariable("pageNum") Integer pageNum,
                           @PathVariable("pageSize") Integer pageSize) throws JSONException, JsonProcessingException, JSONException, JsonProcessingException {
        String newsList = newService.getNewsList(pageNum, pageSize);
        System.out.println(newsList);
        return newsList;
    }
}
